Description:
MCS detects methods
that can be made
class.
Methods that do not access instance variables of the declaring class
should be made
class. Overridden methods and methods
that may be designed to be overridden (virtual public and
protected methods) are skipped because they cannot be
class.
Incorrect:
IdGenerator = class
private
class var id:integer;
public
function NextId():integer;
end;
...
function IdGenerator.NextId():integer;
begin
id := id + 1;
result := id;
end;
Correct:
IdGenerator = class
private
class var id:integer;
public
class function NextId():integer;
end;
...
class function IdGenerator.NextId():integer;
begin
id := id + 1;
result := id;
end;